// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables
import 'dart:ui';

import 'package:flutter/material.dart';

import 'package:junyeyishu/utils/utils.dart';
import 'package:junyeyishu/widgets/QGWidget.dart';
import 'package:junyeyishu/widgets/QGListState.dart';
import 'package:junyeyishu/widgets/QGNavigationBar.dart';

import 'widgets/QGColrfulSynthesisCell.dart';

class QGColrfulSynthesisList extends StatefulWidget {
  const QGColrfulSynthesisList({super.key});
  @override
  State<QGColrfulSynthesisList> createState() => _QGColrfulSynthesisListState();
}

class _QGColrfulSynthesisListState extends QGListState<QGColrfulSynthesisList> {
  @override
  void initState() {
    super.initState();

    listURL = url_index_randomSynthesisEventList;
    listKey = "list";

    onRefresh();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Stack(
          children: [
              QGImage(asset: "colorful_bg", width: kScreenWidth),

            Column(
              children: [
              SizedBox(height: 103.rpx),
              buildList(),
            ]),
            buildTop(),
          ],
        ));
  }

  buildTop() {
    return Container(
      child: QGNavigationBar(
          leftItem: GestureDetector(
            onTap: () {
              Navigator.of(context).pop();
            },
            child: Container(
              padding: EdgeInsets.all(15.rpx),
              child: QGImage(asset: "nav_back_white",width: 20.rpx),
            ),
          ),
          title: "",
          titleStyle: TextStyle(
            color: Color(0xFF111111),
            fontSize: 16.rpx,
            fontWeight: FontWeight.normal,
          )),
    );
  }

  @override
  itemBuilder(context, index, data) {
    return GestureDetector(
        onTap: () {
          if (!User.isLogin) {
            Navigator.of(context).pushNamed(PageLogin);
            return;
          }

          Navigator.of(context)
              .pushNamed(PageColorfulSynthesis, arguments: data["id"]);
        },
        child: QGNFTColrfulComposeCell(data: data));
  }
}
